#!/bin/bash
yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
groupadd www && useradd -g www www -s /bin/false
cd /usr/local/src &&
  mkdir /usr/local/pcre &&
  tar -zxvf pcre-8.35.tar.gz &&
  cd pcre-8.35 &&
  ./configure --prefix=/usr/local/pcre &&
  make && make install
cd /usr/local/src &&
  mkdir /usr/local/openssl &&
  tar -zxvf openssl-1.0.1i.tar.gz &&
  cd openssl-1.0.1i &&
  ./config --prefix=/usr/local/openssl &&
  make && make install &&
  echo 'export PATH=$PATH:/usr/local/openssl/bin' >>/etc/profile &&
  source /etc/profile
cd /usr/local/src &&
  mkdir /usr/local/zlib &&
  tar zxvf zlib-1.2.8.tar.gz &&
  cd zlib-1.2.8 &&
  ./configure --prefix=/usr/local/zlib &&
  make && make install
cd /usr/local/src &&
  tar -zxvf nginx-1.6.1.tar.gz &&
  cd nginx-1.6.1 &&
  ./configure --prefix=/usr/local/nginx \
    --without-http_memcached_module \
    --user=www \
    --group=www \
    --with-http_stub_status_module \
    --with-http_ssl_module \
    --with-http_gzip_static_module \
    --with-openssl=/usr/local/src/openssl-1.0.1i \
    --with-zlib=/usr/local/src/zlib-1.2.8 \
    --with-pcre=/usr/local/src/pcre-8.35 \
    --with-http_stub_status_module \
    --with-http_sub_module \
 &&
  make && make install &&
  echo "安装NGINX完毕！"
